#include<stdio.h>
#include<algorithm>
using namespace std;
const int N=100005;

struct node{
	int l,r,p;
};

int T,n,m,k,L,V,ans;
int d[N],v[N],a[N],p[N];
node b[N];

inline bool cmp(node x,node y){
	return x.r<y.r;
}

int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);

	int i,x,y,g;
	scanf("%d",&T);

	while(T--){
		scanf("%d%d%d%d",&n,&m,&L,&V);
		k=0;

		for(i=1;i<=n;i++)
			scanf("%d%d%d",&d[i],&v[i],&a[i]);

		for(i=1;i<=m;i++) scanf("%d",&p[i]);

		for(i=1;i<=n;i++) if(a[i]>0){
			if(v[i]>V) g=-1;
			else g=(V*V-v[i]*v[i])/(a[i]*2);
			
			x=upper_bound(p+1,p+m+1,d[i]+g)-p;

			if(x<=m) b[++k]=(node){x,m};
		}else if(a[i]<0){
			if(v[i]>V){
				a[i]=-a[i];
				g=(v[i]*v[i]-V*V+a[i]*2-1)/(a[i]*2);
				x=lower_bound(p+1,p+m+1,d[i])-p;
				y=lower_bound(p+1,p+m+1,d[i]+g)-p-1;

				if(x<=y) b[++k]=(node){x,y};
			}
		}else if(v[i]>V){
			x=lower_bound(p+1,p+m+1,d[i])-p;

			if(x<=m) b[++k]=(node){x,m};
		}

		sort(b+1,b+k+1,cmp);
		x=0;
		ans=m;

		for(i=1;i<=k;i++)
		if(x<b[i].l) x=b[i].r,ans--;

		printf("%d %d\n",k,ans);
	}

	return 0;
}